package demo1;


abstract class Shape{
    abstract void drow();//抽象类中的抽象方法
}

class Cycle extends Shape{
    //继承之后必须重写父类中的抽象方法
    @Override
    void drow(){
        System.out.println("画一个圆圈！");
    }

}
class Dog extends Shape{
    @Override
    void drow() {
        System.out.println("画一只狗！");
    }
}
class Cat extends Shape{
    @Override
    void drow() {
        System.out.println("画一只猫！");
    }
}
public class Test1 {
    public static void main(String[] args) {

        Shape shape = new Cycle();//向上转型，父类引用指向子类对象
        Shape shape2 = new Dog();
        Shape shape3 = new Cat();
        Shape[] shape4 = {shape,shape2,shape3};
        for(int i = 0;i < shape4.length;i++){
            shape4[i].drow();
        }
        /*shape.drow();//可以通过父类引用调用子类的重写方法
        shape2.drow();
        shape3.drow();
*/
    }
}
